import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';

@Entity()
//菜单实体
export class Menu {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column()
  path: string; //相对父节点

  @Column({ nullable: true })
  icon: string;

  @Column({ nullable: true })
  parentId: number; //父级菜单id

  @Column({ type: 'enum', enum: ['directory', 'page'], default: 'directory' })
  type: 'directory' | 'page'; //目录还是页面

  @Column({ nullable: true })
  component: string; // 仅 type=page 时有效

  @Column({ nullable: true })
  fullPath: string; // 完整路径，前端可直接使用


  // @Column({nullable:true})
  // systemFlag: string;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  createdAt: Date;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  updatedAt: Date;
}
